package office.poi.excel.utils;

import office.poi.excel.enums.PropertyType;

public class ErrorMsgUtils {
	private static final String Email = "邮箱格式不正确";
	private static final String IdCard = "身份证格式不正确";
	private static final String Phone = "电话格式不正确";
	private static final String Mobile = "手机格式不正确";
	private static final String Digit = "不是正整数或负整数";
	private static final String Decimals = "不是正整数或正浮点数";
	private static final String Chinese = "不是中文";
	private static final String URL = "URL地址不正确";
	private static final String Postcode = "邮编格式不正确";
	private static final String IpAddress = "IP地址格式不正确";
	private static final String Integer = "不是正数";

	public static String getValidateErrorMsg(PropertyType propertyType,String s) {
		if (propertyType.equals("URL")) {
			if(!RegexUtils.checkURL(s)) return URL;
		} else if (propertyType.equals("Email")) {
			if(!RegexUtils.checkEmail(s)) return Email;
		} else if (propertyType.equals("Phone")) {
			if(!RegexUtils.checkPhone(s)) return Phone;
		} else if (propertyType.equals("Mobile")) {
			if(!RegexUtils.checkMobile(s)) return Mobile;
		} else if (propertyType.equals("Digit")) {
			if(!RegexUtils.checkDigit(s)) return Digit;
		} else if (propertyType.equals("Decimals")) {
			if(!RegexUtils.checkDecimals(s)) return Decimals;
		} else if (propertyType.equals("Chinese")) {
			if(!RegexUtils.checkChinese(s)) return Chinese;
		} else if (propertyType.equals("Postcode")) {
			if(!RegexUtils.checkPostcode(s)) return Postcode;
		}  else if (propertyType.equals("IpAddress")) {
			if(!RegexUtils.checkIpAddress(s)) return IpAddress;
		} else if (propertyType.equals("Integer")) {
			if(!RegexUtils.checkDigit(s)) return Integer;
		} else if (propertyType.equals("IdCard")) {
			if(!RegexUtils.checkIdCard(s)) return IdCard;
		}
		return "";
	}
}
